package com.ycx.ycxmybatismanagement.mapper;

import com.github.pagehelper.Page;
import com.ycx.ycxmybatismanagement.dto.ClazzsListDTO;
import com.ycx.ycxmybatismanagement.dto.ClazzDTO;
import com.ycx.ycxmybatismanagement.pojo.Clazz;
import com.ycx.ycxmybatismanagement.vo.ClazzsListVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzsMapper {
    /**
     * 班级分页
     * @param clazzsListDTO
     * @return
     */
    Page<ClazzsListVO> clazzsPageList(ClazzsListDTO clazzsListDTO);

    /**
     * 删除班级
     * @param id
     */
    void deleteClazzById(Integer id);

    /**
     * 班级添加
     * @param clazzDTO
     */
    void addClazz(ClazzDTO clazzDTO);

    ClazzsListVO selectClazzById(Integer id);
    @Delete("delete from student where clazz_id =#{id}")
    void deleteStudentByClazzId(Integer id);

    void updateClazz(Clazz clazz);
    @Select("select count(*) from student where clazz_id =#{id}")
    int getStudentSize(Integer id);
    @Select("select * from clazz")
    List<ClazzsListVO> selectClazzList();
    @Select("select name from student where name =#{name}")
    String selectClazzName(String name);
}
